package thread;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

public class SleepDemo2 {
    public static void main(String[] args) {
        Thread z = new Thread("黄总"){
          public void run(){
              System.out.println(getName()+"说:困了睡一会吧");
              try {
                  Thread.sleep(5000000);
                  System.out.println(getName()+"睡醒了");
              } catch (InterruptedException e) {
                  System.out.println(getName()+"惭愧说道:我错了李总");
              }
          }
        };

        Thread l = new Thread("李总"){
          public void run(){
              System.out.println(getName()+"来到了学校");
              for (int i =0;i<6;i++){
                  System.out.println(getName()+"正在学习");
              try {
                  Thread.sleep(1000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              }
              System.out.println(getName()+"学习完了");
              System.out.println(getName()+"看见黄总正在睡觉,叫醒了他说:不学习还睡?");
              z.interrupt();
          }
        };
        z.start();
        l.start();

    }
}
